using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using HTSwitchServerNamespace;

namespace TestServerHTSwitchNamespace
{
	public partial class TestServerHTSwitch : Form
	{
		private bool bIsRunning;
       // private bool bIsRunningTraza;
		private Color clBGColor;
		private Color clFGColor;

    //    private Color clBGColorTraza;
     //   private Color clFGColorTraza;

		private CHTSwitchServer srvHTSwitch;
		/// <summary>
        /// Constructor del tester del server HTSwitch
		/// </summary>
		public TestServerHTSwitch()
		{
			InitializeComponent();
			bIsRunning = false;
			clBGColor = buttonStartStop.BackColor;
			clFGColor = buttonStartStop.ForeColor;

           // clBGColorTraza = buttonStartStopTraza.BackColor;
           // clFGColorTraza = buttonStartStopTraza.ForeColor;

            srvHTSwitch = new CHTSwitchServer();
		}

		/// <summary>
        /// Metodo asociado al Button Start/Stop del dialogo. Lanza o frena el servidor de HTSwitch
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void buttonStartStop_Click(object sender, EventArgs e)
		{
			try
			{
				if (bIsRunning)
				{
                    srvHTSwitch.StopServer();
                    srvHTSwitch.stopServerMantenimientoDiario();              //FD 6-2-13
                    //srvHTSwitch.stopServerMantenimientoPrioritario();         //FD 6-2-13
                    //srvHTSwitch.stopControldeNuevosUsuarios();                //FD 6-2-13

					((Button)sender).Text = "Start";
					((Button)sender).BackColor = clBGColor;
					((Button)sender).ForeColor = clFGColor;
				}
				else
				{
                    srvHTSwitch.LanzarServer();
                    srvHTSwitch.lanzarMantenimientoDiario();                  //FD 6-2-13
                   //srvHTSwitch.lanzarMantenimientoPrioritario();             //FD 6-2-13
                    //srvHTSwitch.lanzarControldeNuevosUsuarios();              //FD 6-2-13  

					((Button)sender).Text = "Stop";
					((Button)sender).BackColor = Color.Red;
					((Button)sender).ForeColor = Color.White;
				}
				bIsRunning = !bIsRunning;
                
			}
			catch (Exception ex)
			{
				MessageBox.Show("Carajo, algo fallo:" + ex.Message);
			}
		}

        /*
        private void buttonStartStop_ClickTraza(object sender, EventArgs e)
        {
            try
            {
                if (bIsRunningTraza)
                {
                    srvHTSwitch.stopServerMantenimiento();
                    ((Button)sender).Text = "Start";
                    ((Button)sender).BackColor = clBGColorTraza;
                    ((Button)sender).ForeColor = clFGColorTraza;
                }
                else
                {
                    srvHTSwitch.lanzarLimpiadorMantenimiento();
                    ((Button)sender).Text = "Stop";
                    ((Button)sender).BackColor = Color.Red;
                    ((Button)sender).ForeColor = Color.White;
                }
                bIsRunningTraza = !bIsRunningTraza;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Carajo, algo fallo:" + ex.Message);
            }
        }
         * */
	}

}